<div class="layui-card">
    <div class="layui-card-header">
        <h2 class="header-title">会员管理</h2>
    </div>
    <div class="layui-card-body">
        <form id="search-form" class="layui-form">
            <div class="layui-form-item">
                <label class="layui-form-label">会员昵称</label>
                <div class="layui-input-inline">
                    <input type="text" name="nick" class="layui-input"/>
                </div>
                <label class="layui-form-label">会员状态</label>
                <div class="layui-input-inline">
                    <select name="state">
                        <option value=""></option>
                        <option value="0">取消关注</option>
                        <option value="1">关注</option>
                    </select>
                </div>
                <div class="layui-input-inline">
                    <button class="layui-btn" type="button" lay-active="reloadTab" lay-submit="">查询</button>
                </div>
            </div>
        </form>


        <table id="tableElement" lay-filter="tableElement"></table>

    </div>

</div>

<script type="text/javascript">
    layui.use(['tools', 'setter', 'form', 'table', 'admin', 'layer'], function () {
        const tools = layui.tools;
        const config = layui.setter;
        const form = layui.form;
        const layer = layui.layer;
        const $ = layui.$;
        let table = layui.table;
        methods = {
            renderTable: function () {
                // 渲染表格
                return table.render({
                    elem: '#tableElement',
                    url: '/mall/api/seller/member/list',
                    where: tools.serialize(),
                    page: true,
                    cellMinWidth: 100,
                    cols: [[
                        {field: 'nick', sort: true, title: '会员昵称'},
                        {field: 'sellerGradeName', sort: true, title: '店铺会员等级'},
                        {field: 'gradeValue', sort: true, title: '店铺会员经验值'},
                        {field: 'sysGradeName', sort: true, title: '会员等级'},
                        {field: 'sysGradeValue', sort: true, title: '会员经验值'},
                        {
                            field: 'state', sort: true, title: '状态', templet: function (row) {
                            if (1 == row.state) {
                                return "关注"
                            } else if (0 == row.state) {
                                return "<label style='color: #FF5722'>取消关注</label>"
                            }
                        }
                        },
                        {field: 'createTime', sort: true, title: '关注时间'}
                    ]]
                });
            },
            reloadTab: function () {
                table.reload('tableElement', {
                    where: tools.serialize(), page: {
                        curr: 1
                    }
                });
            }
        };
        methods.renderTable();
        tools.event(methods);

    });
</script>